package cn.edu.njpi.web;

import cn.edu.njpi.utils.FileUtils;
import cn.edu.njpi.utils.InformUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.io.IOException;

/**
 * @author 朱宗辉
 * @version V1.0
 * @Package cn.edu.njpi.web
 * @date 2022/4/19 7:20 PM
 */
@Controller
public class IndexWeb {
    @Value("${welcome.file.url}")
    private String welcomeFileUrl;
    @Value("${caoxingfen.url}")
    private String url;

    @RequestMapping(value = "/index")
    public ModelAndView index() throws IOException {
        ModelAndView modelAndView = new ModelAndView("/index");
        modelAndView.addObject("title", InformUtils.title);
        modelAndView.addObject("welcome", FileUtils.readFile(welcomeFileUrl));
        modelAndView.addObject("url", url);
        return modelAndView;
    }
}
